/**
 *                     Remixvym (version 0.8.3)
 *             Copyright (c) 2010 by RemixLab, DISI-UNAL
 *            http://www.disi.unal.edu.co/grupos/remixlab/
 *
 * This Java package provides classes to visualize Mind Maps created in VYM
 * (View Your Mind) in a Processing Sketch
 *
 * @author Alvaro Lopez, Juan Baquero
 *
 * This source file is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 3 of the License, or (at your option)
 * any later version.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * A copy of the GNU General Public License is available on the World Wide Web
 * at <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by
 * writing to the Free Software Foundation, 51 Franklin Street, Fifth Floor
 * Boston, MA 02110, USA
 */
package remixlab.remixvym.core.graphics.node;

import processing.core.PApplet;
import processing.core.PGraphics;
import remixlab.remixvym.core.graphics.StyleGraph;
import remixlab.remixvym.core.mindmap.Node;

/**Wrapper class that draws nodes using an instance of any class that
 * implements NodeShape {@link remixlab.remixvym.core.graphics.node.NodeShape} 
 * */
public class NodeGraph  implements ConstansColor {
	
	/**Constructor
	 * @param st The style used*/
	public NodeGraph(StyleGraph st)
	{
		style = st;
		changeStyle();
	}

	/**Draws the node using a color code and the shape implementation stored in {@link #nodeType}*/
	public void drawNode(Node node, PApplet parent, int color, PGraphics pg){
		if (node.hide)
			return;
		
		nodeType.prepareNode(node, style);

		//Test of new NodeStyles
		/*if(nodeType instanceof RoundedRectNode){
		if(color != ConstansColor.NonSelect)
			System.out.println("Si llega un color diferente");
		}*/

		//Paint Colors 
		nodeType.setColor(color, parent, style,pg);
		// draw node
		nodeType.draw(node, parent,pg,style);
		//DRAW Text, Icons and Emoticons
		nodeType.content(node, parent, style,pg);
	}
	
	/**Draws the node using a color code and the shape implementation stored in {@link #nodeType}*/
	public void drawNode_auxiliar(Node node, PApplet parent, int color, PGraphics pg,float K,int dx, int dy){
		if (node.hide)
			return;
		
		nodeType.prepareNode(node, style);

		//Paint Colors, 
		nodeType.setColor(color, parent, style,pg);
		// draw node
		nodeType.draw(node, parent,pg,style);//no hace nada ¿?
		//DRAW Text, Icons and Emoticons
		
		//float fuente_escalada = style.sizeFontRoot;
		//style.sizeFontRoot = 3*fuente_escalada;
		nodeType.content_auxiliar(node, parent, style,pg,K,dx,dy);
	}
	
	public void drawNode(Node node, PApplet parent, int color, int nodeTypeId, PGraphics pg){
		if (node.hide)
			return;
		NodeShape tempNodeType = style.getNodeStyle(nodeTypeId);
		tempNodeType.prepareNode(node, style);
		//Paint Colors, 
		tempNodeType.setColor(color, parent, style,pg);
		// draw node
		tempNodeType.draw(node, parent,pg,style);//no hace nada
		//DRAW Text, Icons and Emoticons
		tempNodeType.content(node, parent, style,pg);
		//changeStyle();
	}
	
	
	/**Changes the style used to paint nodes*/
	public void changeStyle (){
		nodeType = style.getNodeStyle();
	}
	
	/**A reference to an implementation of NodeShape {@link remixlab.remixvym.core.graphics.node.NodeShape}, the node painter*/
	private NodeShape nodeType;
	/** Style to use. See {@link remixlab.remixvym.core.graphics.StyleGraph}*/
	private StyleGraph style;
}
